package com.zyk.scaffold.oauth.controller.token;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

@Data
@ApiModel("密码登录请求信息")
public class TokenLoginPasswordRequest implements Serializable {
    private static final long serialVersionUID = -6949882219841285959L;
    @ApiModelProperty(value = "授权账户", required = true)
    @NotBlank(message = "授权账户不能为空")
    private String account;
    @ApiModelProperty(value = "租户编码", required = true)
    private String tenantCode;
    @ApiModelProperty(value = "密码", required = true)
    @NotBlank(message = "密码不能为空")
    private String password;
    @ApiModelProperty(value = "客户端ID", required = true)
    @NotBlank(message = "客户端ID不能为空")
    private String clientId;
    @ApiModelProperty(value = "客户端密钥", required = true)
    @NotBlank(message = "客户端密钥不能为空")
    private String clientSecret;
    @ApiModelProperty(value = "验证图像ID", required = true)
    @NotBlank(message = "验证图像ID不能为空")
    private String graphId;
    public TokenLoginRequest toTokenLoginRequest(){
        TokenLoginRequest tokenLoginRequest = new TokenLoginRequest();
        tokenLoginRequest.setGrantType("password");
        tokenLoginRequest.setAccount(this.getAccount());
        tokenLoginRequest.setPassword(this.getPassword());
        tokenLoginRequest.setClientId(this.getClientId());
        tokenLoginRequest.setClientSecret(this.getClientSecret());
        tokenLoginRequest.getRequestParam().put("graphId", graphId);
        tokenLoginRequest.getRequestParam().put("tenantCode", tenantCode);
        return tokenLoginRequest;
    }
}
